/*******************************************************************************
 * Copyright 2013 Mindaugas Idzelis
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package incontrol.bf3.protocol.events.datatype;

import incontrol.bf3.state.ServerState;

import com.google.common.base.Objects;

public class Squad {

	public final int teamId;
	public final int squadId;

	public Squad(int teamId, int squadId) {
		this.teamId = teamId;
		this.squadId = squadId;
	}

	public int getTeamId() {
		return teamId;
	}

	public int getSquadId() {
		return squadId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + squadId;
		result = prime * result + teamId;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Squad other = (Squad) obj;
		if (squadId != other.squadId)
			return false;
		if (teamId != other.teamId)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return Objects
				.toStringHelper(this)
				.addValue(
						ServerState.getDefaultTeamName(teamId) + " "
								+ Squad.getSquadName(squadId))
				.add("teamId", teamId).add("squadId", squadId).toString();
	}

	public static String getSquadName(int squad) {
		return SQUADS[squad];
	}

	private static final String[] SQUADS = new String[] {	
		//@formatter:off
			new String("None"),
			new String("Alpha"),
			new String("Bravo"),
			new String("Charlie"), 
			new String("Delta"), 
			new String("Echo"), 
			new String("Foxtrot"), 
			new String("Golf"), 
			new String("Hotel"), 
			new String("India"), 
			new String("Juliet"), 
			new String("Kilo"), 
			new String("Lima"), 
			new String("Mike"), 
			new String("November"), 
			new String("Oscar"), 
			new String("Papa"), 
			new String("Quebec"), 
			new String("Romeo"), 
			new String("Sierra"), 
			new String("Tango"), 
			new String("Uniform"), 
			new String("Victor"), 
			new String("Whiskey"), 
			new String("X-Ray"), 
			new String("Yankee"), 
			new String("Zulu")
			};
	//@formatter:on
}
